package org.soarsky.wealthchengdu.google.map;





import org.soarsky.wealthchengdu.R;

import android.content.Context;




public class MapOverlaysControlFactory {
	//private LineBaiduOverlays lineBaiduOverlays = null;
	//private LocationBaiduOverlays locationBaiduOverlays = null;
	//private MarkItemBaiduOverlays markItemBaiduOverlays = null;
	private LineGoogleOverlays lineGoogleOverlays = null;
	private LocationGoogleOverlays locationGoogleOverlays = null;
	private MarkItemGoogleOverlays markItemGoogleOverlays = null;
	private MapConstant.MAP_TYPE mapType = null;
	private Context context = null;
	private static MapOverlaysControlFactory controlFactory = null;
	public static MapOverlaysControlFactory getInstance(){
		return controlFactory;
	}
	public MapOverlaysControlFactory( Context context){
		this.context = context;
		controlFactory = this;
	}
	/*public void initBaiduOverlays(com.baidu.mapapi.MapView mapView){
		if(null==mapView)return;
		lineBaiduOverlays = new LineBaiduOverlays(mapView);
		locationBaiduOverlays = new LocationBaiduOverlays(context,mapView);
		markItemBaiduOverlays = new MarkItemBaiduOverlays(null,mapView);
		mapView.getOverlays().add(lineBaiduOverlays);
		mapView.getOverlays().add(locationBaiduOverlays);
		mapView.getOverlays().add(markItemBaiduOverlays);
		mapType = MapConstant.MAP_TYPE.BAIDU_MAP;
		
	}*/
	public void initGoogleOverlays(com.google.android.maps.MapView mapView){
		if(null==mapView)return;
		lineGoogleOverlays = new LineGoogleOverlays(mapView);
		locationGoogleOverlays = new LocationGoogleOverlays(context,mapView);
		markItemGoogleOverlays = new MarkItemGoogleOverlays(context.getResources().getDrawable(R.drawable.mark_start_flag),mapView);
		mapView.getOverlays().add(lineGoogleOverlays);
		mapView.getOverlays().add(locationGoogleOverlays);
		mapView.getOverlays().add(markItemGoogleOverlays);
		mapType = MapConstant.MAP_TYPE.GOOGLE_MAP;
	}
	public MarkOverlaysInterface getMarkOverlays(){
		if(null==mapType)return null;
		switch (mapType) {
		//case BAIDU_MAP:
			//return markItemBaiduOverlays;
			
		case GOOGLE_MAP:
			
			return markItemGoogleOverlays;
		default:
			return null;
		}
	}
	public LocationOverlaysInterface getLocationOverlays (){
		if(null==mapType)return null;
		switch (mapType) {
		case GOOGLE_MAP:
			return locationGoogleOverlays;
		//case BAIDU_MAP:
			//return locationBaiduOverlays;
		default:
			return null;
		}
	}
	public LineOverlaysInterface getLineOverlays(){
		if(null==mapType)return null;
		switch (mapType) {
		
		
		//case BAIDU_MAP:
			
			//return lineBaiduOverlays;
		case GOOGLE_MAP:
			
			return lineGoogleOverlays;
		default:
			return null;
		}
		
	}
	public void destroy(){
		/*if(null!=lineBaiduOverlays){
			lineBaiduOverlays.distory();
			lineBaiduOverlays = null;
		}
		if(null!=locationBaiduOverlays){
			locationBaiduOverlays.freeLocation();
			locationBaiduOverlays = null;
		}
		if(null!=markItemBaiduOverlays){
			markItemBaiduOverlays.distory();
			markItemBaiduOverlays = null;
		}*/
		if(null!=lineGoogleOverlays){
			lineGoogleOverlays.distory();
			lineGoogleOverlays = null;
		}
		if(null!=locationGoogleOverlays){
			locationGoogleOverlays.freeLocation();
			locationGoogleOverlays = null;
		}
		if(null!=markItemGoogleOverlays) {
			markItemGoogleOverlays.distory();
			markItemGoogleOverlays = null;
		}
	}

}
